<%@ page language="java" pageEncoding="ISO-8859-1"%>
<jsp:directive.page import="java.util.ArrayList"/>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
    
    <title>iicregister.jsp</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

 <script type="text/javascript">
 
 
 
 function getcommpst(f)
      { 
        
         var x;
         v=f.ds.value;
      try
      {
          x=new XMLHttpRequest();
      }
     catch(e)
      {
          try
          {
             x=new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch(e)
          {
                try
                 {
                    x=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch(e)
                 {
                   alert("Browser not supported");
                }
           }
     }
    
   
    x.open("get","/police/iiccommregd.do?iiccommregp=getcommpolicestation&CMPD="+v,true);
   
   
    x.send(null);
    x.onreadystatechange=f2;
    function f2()
    {
   
    	if(x.readyState==4)
    	{
    	
    		var   bb=x.responseText;
    		  alert("bb="+bb);
    		var  cc= bb.split("#");
    	
    		  alert("cc="+cc);
    		 var psid=cc[0];
 
    		  alert("psid="+psid);
    		 var psna=cc[1];
    		 alert("psna="+psna);
    		var  psid1=psid.split("]");
    		
    		 alert("psid1="+psid1);
    	
    		 
    		var  psid2=psid1[0].split("[");
    		 alert("psid2="+psid2);
    		  
    		  
    		 var psid3=psid2[1].split(",");
    		
   
    		 alert("psid3="+psid3);
    		 
    		 
    		 
    		 var  psna1=psna.split("]");
    		var  psna2=psna1[0].split("[");
    		var  psna3=psna2[1].split(",");
    		alert(psna3)
    		 for(var i=0;i<psid3.length;i++)
    		 {
    		 	
    		 	alert("dd")
    		 	document.forms[0].pst.options[i+1]=new Option(psid3[i],psna3[i]);
    		 }
    		 
    		 
    		  
    		
    	}
    	
    }
    						
  }
    
    
    
    
 
 
 
function checkblank(f)
{
   
   b=f.ds.value
   bb=f.pst.value
   c=f.uc.value
   e=f.dgn.value
   g=f.ad.value
   h=f.dq.value
   i=f.T2.value
   jj=f.T3.value
   k=f.phn.value
   l=f.eid.value
   m=f.g
   n=f.pho.value
   
   o=f.uid.value
   p=f.pwd.value
   q=f.cpwd.value
   var r=f.hn.value
   s=f.ya.value
   t=f.ia
  
   if( (b.match("select")) ||(bb.match("select")) || (c.length==0)||(e.length==0)|| (g.length==0)||(h.length==0)||(i.length==0) || (jj.length==0) || (k.length==0)||(l.length==0)||((m[0].checked==0) &&(m[1].checked==0)) || (n.length==0)||(o.length==0)||(p.length==0)||(q.length==0) ||(r.match("select"))|| (s.length==0)||(t.checked==0))
   {
      alert("pls fill all d fields")
      
      if(b.match("select"))
      {
         document.getElementById("pds").innerText="This field shdnt be left blank"
      }
      if(bb.match("select"))
      {
         document.getElementById("ppst").innerText="This field shdnt be left blank"
      }
      if(c.length==0)
      {
         document.getElementById("puc").innerText="This field shdnt be left blank"
      }
     
      
       if(e.length==0)
      {
         document.getElementById("pdgn").innerText="This field shdnt be left blank"
      }
      
      
      			if(g.length==0)
      			{
         			document.getElementById("pad").innerText="This field shdnt be left blank"
      			}
      			if(h.length==0)
      			{
         			document.getElementById("pdq").innerText="This field shdnt be left blank"
      			}
      			if(i.length==0)
      			{
         			document.getElementById("pdob").innerText="This field shdnt be left blank"
      			}
      			if(jj.length==0)
      			{
         			document.getElementById("pdoj").innerText="This field shdnt be left blank"
      			}
      			if(k.length==0)
      			{
         			document.getElementById("pphn").innerText="This field shdnt be left blank"
      			}
      			if(l.length==0)
      			{
         			document.getElementById("peid").innerText="This field shdnt be left blank"
      			}
      			if((m[0].checked==0) && (m[1].checked==0))
      			{
         			document.getElementById("pg").innerText="This field shdnt be left blank"
      			}
      			if(n.length==0)
      			{
         			document.getElementById("ppho").innerText="This field shdnt be left blank"
      			}
      if(o.length==0)
      {
         document.getElementById("puid").innerText="This field shdnt be left blank"
      }
      if(p.length==0)
      {
         document.getElementById("ppwd").innerText="This field shdnt be left blank"
      }
      if(q.length==0)
      {
         document.getElementById("pcpwd").innerText="This field shdnt be left blank"
      }
      if(r.match("select"))
      {
         document.getElementById("ph").innerText="This field shdnt be left blank"
      }
      if(s.length==0)
      {
         document.getElementById("pya").innerText="This field shdnt be left blank"
      }
       if(t.checked==0)
      {
         document.getElementById("pia").innerText="This field shdnt be left blank"
      }
      
     
     return false;
     }
      else
      {
         if(p!=q)
         {
           alert("Password and confirm password do not match")
           return false
         }
         else if((k.length < 10) || (k.length > 10))
         {
            alert("Invalid contact number")
            document.getElementById("pphn").innerHTML="<font color=red>invalid num</font>"
            return  false
          }
          else
          {
            
            var a=l.indexOf("@")
            var b=l.indexOf(".")
            if((a==-1)||(b==-1))
            {
             alert("Invalid email id")
             document.getElementById("peid").innerHTML="<font color=red>invalid id</font>"
              return false
            }
          
          }
      }
      
  
   }
    
function myonlynum()
{
    if((event.keyCode<48)||(event.keyCode>57))
    {
      alert("enter numeric values")
      event.returnValue=false
    }
}
  




</script>
<script language="javascript" type="text/javascript" src="datetimepicker_css.js"></script>

   <link href="css/style1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="main-out">
<div class="main">
<div class="page">
<div class="top">
<div class="header">
<div class="header-top">
<%@include file="TopHead.jsp" %>
</div>
<div class="topmenu">
<%@include file="TopMenu.jsp" %>
</div>
<div class="">
<img src="images/d3.gif">
</div>
</div>
<div class="content">
<div class="content-left">
<div class="row1">
<div class="img">&nbsp;</div>
<div class="welcome">
<h1 class="title">Welcome to POlice Seva<span></span></h1>
<p>




</p>


<html:form action="iiccommregd" onsubmit="return checkblank(this)">
<% 
	  
 	ArrayList cid=(ArrayList)request.getAttribute("ICM");
   ArrayList cn=(ArrayList)request.getAttribute("ICN");
	 %>
<div align="center">

	<table width="60%">
	<%Object ob1=request.getAttribute("iic");
	if(ob1!=null)
 	{
 	 %>
	<tr>
			<td width="595">
			<p align="center"><%=ob1.toString() %></p>
			</td>
			<td>&nbsp;</td>
		</tr>
		
	<%

}
else 


{
%>
			<tr>
			<td width="595">	
				<fieldset style="padding: 2; width:536; height:379">
				<legend>Personal Details</legend>
				<div align="left">
					<table border="0" width="373" height="385">
					<tr>
					
					         
							<td width="176">Commissionrate division</td>
							<td><html:select property="ds" onchange="getcommpst(this.form)" >
							<html:option value="select">Select one comm div</html:option>
							 <%
					         if(cid !=null)
					         {
					         
							 for(int i=0;i<cn.size();i++)
		    	             {
		    	             System.out.print(cid.get(i).toString());
		    	             %>
							
							
							<html:option value="<%=cid.get(i).toString()%>"> <%=cn.get(i).toString()%></html:option>
							
							<%
							} }
							%>
				
							</html:select>
							</td>
							<td><label id="pds"></label></td>
					</tr>
					<tr>
							<td width="176">Police Station</td>
							<td><html:select property="pst" >
							<html:option value="select">Select one police station</html:option>
							</html:select>
							</td>
							<td><label id="ppst"></label></td>
					</tr>
					<tr>
							<td width="23%">User code</td>
							<td><html:text property="uc"></html:text>
							</td>
							<td><label id="puc"></label></td>
		
						</tr>
						<tr>
							<td width="176%">Designation</td>
							<td><html:text property="des"  value="COMMIIC" readonly="true"></html:text>
							
							</td>
							<td><label id="pdes"></label></td>
							
						</tr>
						<tr>
							<td width="176%" height="41">Name</td>
							<td height="41"><html:text property="dgn"></html:text>
							</td>
							<td><label id="pdgn"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Address</td>
							<td><html:textarea property="ad"></html:textarea>																		
                       		</td>
                       		<td><label id="pad"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Qualification</td>
							<td><html:text property="dq"></html:text>
							</td>
							<td><label id="pdq"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Date of Birth</td>
							<td width="76%">
<input type="text" name="T2" id="demo3" size="20" readonly="readonly" onfocus="javascript:NewCssCal('demo3','ddMMMyyyy','arrow')">
</td>
							<td><label id="pdob"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Date of Joining</td>
							<td width="76%">
<input type="text" name="T3" id="demo4" size="20" readonly="readonly" onfocus="javascript:NewCssCal('demo4','ddMMMyyyy','arrow')">
</td>
							<td><label id="pdoj"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Contact Number</td>
							<td><html:text property="phn" onkeypress="myonlynum()" ></html:text>
							</td>
							<td><label id="pphn"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Email ID</td>
							<td><html:text property="eid"></html:text>
							</td>
							<td><label id="peid"></label></td>
		
						</tr>
						<tr>
							<td width="23%">Gender</td>
							<td width="45%">
							<html:radio property="g" value="Male">male</html:radio>
							<html:radio property="g" value="Female">female</html:radio>	
							</td>	
							<td><label id="pg"></label></td>
		
							
						</tr>
						<tr>
							<td width="23%">Photo</td>
							<td>
							<html:file property="pho"></html:file>
							</td>
							<td><label id="ppho"></label></td>
		
						</tr>
					</table>
				</div>
				&nbsp;</fieldset></td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td width="595">	
				<fieldset style="padding: 2; width:537; height:188">
				<legend>Login Details</legend>
				<div align="left">
					<table border="0" width="108%">
						<tr>
							<td width="176">User ID</td>
							<td><html:text property="uid"></html:text>
								</td>
								<td><label id="puid"></label></td>
		
						</tr>
						<tr>
							<td width="176" height="41">Password </td>
							<td height="41"><html:password property="pwd"></html:password>
							</td>
							<td><label id="ppwd"></label></td>
		
						</tr>
						<tr>
							<td width="176">Confirm password</td>
							<td><html:password property="cpwd"></html:password>
							</td>
							<td><label id="pcpwd"></label></td>
		
						</tr>
						<tr>
							<td width="176">Hint Question</td>
							<td><html:select property="hn" >
							<html:option value="select">Select Your Question</html:option>
							<html:option value="Your first teachers name">Your first teacher's name</html:option>
							<html:option value="Your fathers middle name">Your father's middle name</html:option>
							<html:option value="Which city you born">Which city you born</html:option>
							<html:option value="Your school name">Your school name</html:option>
							<html:option value="Your best friend in school">Your best friend in school</html:option>
							</html:select>
						
							</td>
							<td><label id="ph"></label></td>
		
						</tr>
						<tr>
							<td width="176">Your Answer</td>
							<td><html:text property="ya"></html:text>
							&nbsp;</td>
							<td><label id="pya"></label></td>
		
						</tr>
					</table>
				</div>
				&nbsp;</fieldset></td>
			<td>&nbsp;</td>
		</tr>
		<%
			String captcha = (String) session.getAttribute("captcha");
			
			 %>
		
		<input type="hidden" name="code" value="<%=captcha %>">
		<tr>
			<td width="595"><img src="http://localhost:8085/police/servlet/CaptchaServlet"> </td>
		
			<td>&nbsp;</td>
		
		</tr>
		
		
		<tr>
			<td width="595"><input type="text" name="cap"></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		
		</tr>

		<tr>
			<td width="595"><html:checkbox property="ia" value="I agree">I agree</html:checkbox> </td>
			<td>&nbsp;</td>
			<td><label id="pia"></label></td>
		
		</tr>
		<tr>
			<td width="595">
			<p align="center"></p>
			<html:submit value="IICCOMMRegister" property="iiccommregp"></html:submit> </td>
			<td>&nbsp;</td>
		</tr>
		<%} %>
	</table>
</div>
</html:form>








</div>
</div>
</div>
<div class="content-right">
<%@include file="SideMenu.jsp" %>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>
</div>
<div class="bottom">
<!--DO NOT Remove The Footer Links-->
<p><%@include file="Footer.jsp"  %><br>
<!--DO NOT Remove The Footer Links-->
</p>
</div>
</div>
</div>
</div>
</body>
</html:html>

